class EfTextFormatter extends EfFieldFormatter

Provides formatting methods for text, text_long and text_with_summary field types.

Methods

__construct(EntityMetadataWrapper $property, bool $isMultivalue)

Constructor.

array|string
value()

Returns the current field item as a raw array.

array
values()

Returns all raw field items in an array.

all()

Returns an array of all field items as EfFieldFormatter objects.

array
setDelta($delta)

Set the current field delta.

bool
isDeltaValid(null $delta = NULL)

Checks if the given or current field delta exists.

bool
notEmpty()

Shortcut for the possible not so easy to understand isDeltaValid() method.

bool
isAccessible()

Check if current user is allowed to view this field.

getIterator()

Implementing IteratorAggregate interface.

int
count()

Implementing Countable interface.

$this
setTruncate(int $truncate)

Sets the number of characters after which to truncate.

string
text()

Returns the textual value of this field at the current delta.

string
summary(int $truncate)

Returns the summary of this text or a truncated version of the text.

string
truncate(int $truncate, string $ellipsis = '…')

Hard cuts the string after a given character count and adds an ellipsis.

__toString()

No description

Details

in EfFieldFormatter at line 23
__construct(EntityMetadataWrapper $property, bool $isMultivalue)

Constructor.

Parameters

EntityMetadataWrapper $property The value of this field wrapped by an EntityMetadataWrapper.
bool $isMultivalue Whether this field has a cardinality greater than one.

in EfFieldFormatter at line 43
array|string value()

Returns the current field item as a raw array.

Return Value

array|string

in EfFieldFormatter at line 52
array values()

Returns all raw field items in an array.

Return Value

array

in EfFieldFormatter at line 61
EfFieldFormatter[] all()

Returns an array of all field items as EfFieldFormatter objects.

Return Value

EfFieldFormatter[]

in EfFieldFormatter at line 74
array setDelta($delta)

Set the current field delta.

Parameters

$delta

Return Value

array

in EfFieldFormatter at line 91
bool isDeltaValid(null $delta = NULL)

Checks if the given or current field delta exists.

Parameters

null $delta

Return Value

bool

in EfFieldFormatter at line 102
bool notEmpty()

Shortcut for the possible not so easy to understand isDeltaValid() method.

Return Value

bool

in EfFieldFormatter at line 113
bool isAccessible()

Check if current user is allowed to view this field.

Can be needed if a module like field_permissions is in use.

Return Value

bool True, if current user is allowed to view this field.

in EfFieldFormatter at line 124
EfFieldFormatterIterator getIterator()

Implementing IteratorAggregate interface.

If we wrap a list, we return an iterator over the data list.

in EfFieldFormatter at line 133
int count()

Implementing Countable interface.

Return Value

int The number of items of this field.

at line 216
$this setTruncate(int $truncate)

Sets the number of characters after which to truncate.

Parameters

int $truncate Number of characters after which to truncate.

Return Value

$this

at line 226
string text()

Returns the textual value of this field at the current delta.

Return Value

string The textual value of this field at the current delta.

at line 246
string summary(int $truncate)

Returns the summary of this text or a truncated version of the text.

For truncating the core text_summary function is used; this function uses the character count only as a rough guideline.

If you need accurate truncating at a given char count, use the truncate method.

Parameters

int $truncate (Optional) Number of characters after which to truncate. If not specified the value of member variable is taken.

Return Value

string The summary of this text or a truncated version of the text.

at line 270
string truncate(int $truncate, string $ellipsis = '…')

Hard cuts the string after a given character count and adds an ellipsis.

Any HTML is stripped of.

For more sensible but unpredictable truncating use the summary method.

Parameters

int $truncate (Optional) Number of characters after which to truncate. If not specified the value of member variable is taken.
string $ellipsis A string to be added at the end. Defaults to the "…".

Return Value

string

at line 296
__toString()